//-------------------------------------------------------------------
//	Copyright (c) 2012-2014 Zhirnov Andrey
//	This file is part of the "UXGEN-ES" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------

#pragma once

#include "UI/Types/Types.h"

namespace Engine
{
namespace UI
{

	class UILocaleSettingsResource;
	SHARED_POINTER( UILocaleSettingsResource );



	//
	// UI Localization Settings Resource
	//

	class UILocaleSettingsResource : public Resource
	{
		friend struct ::MetaData::UILocaleSettingsCfg;

	// types
	public:

		struct UILSettingsLoadParams : ResLoadParams
		{
		// methods
		public:
			UILSettingsLoadParams () : ResLoadParams( Signature() )
			{}

			static signature_t Signature ()
			{
				return CompileTime::TSignature8< 'U', 'I', 'L', 'S', 'T', 'N', 'G' >::value;
			}
		};

		typedef Graphics::FontLoader::char_intervals_t	char_intervals_t;

		//
		// Language Info
		//
		struct LangInfo
		{
			string				name,			// example: "English"
								iso3Name;		// example: "eng"
			char_intervals_t	charIntervals;
		};

		typedef array< LangInfo >	lang_array_t;


		// ID + filename
		typedef map< uint, string >		files_map_t;


	// variables
	private:
		lang_array_t		_languages;
		files_map_t			_localeFiles;
		uint				_defaultLocale;


	// methods
	public:
		UILocaleSettingsResource (const EngineSubSystemsRef ess) : 
			Resource( EResource::UI_LOCALE_SETTINGS, ess )
		{}


		~UILocaleSettingsResource ()
		{}


		lang_array_t const &	GetLanguages ()			const	{ return _languages; }
		files_map_t	const &		GetLocaleFiles ()		const	{ return _localeFiles; }
		uint					GetDefaultLocaleId ()	const	{ return _defaultLocale; }
		
		
		// Resource //
		virtual bool SwapData (const ResourcePtr &res) override
		{
			CHECK_ERR( Resource::SwapData( res ) );

			UILocaleSettingsResource *	lsettigns = res.ToPtr< UILocaleSettingsResource >();

			// TODO
			return true;
		}


		virtual bool IsLoadedWithParams (const ResLoadParams &params) const override
		{
			return true;
		}
		

		virtual bool IsValid () const override
		{
			return not _languages.Empty();
		}


		static UILocaleSettingsResourcePtr New (const EngineSubSystemsRef ess)
		{
			return BaseObject::_New( new UILocaleSettingsResource( ess ) );
		}


		static UILSettingsLoadParams GetDefaultLoadParams ()
		{
			return UILSettingsLoadParams();
		}
	};


}	// UI
}	// Engine